
function submitUserData() {
  const data = {};
  data.name = $("#name").val();
  data.email = $("#email").val();
  data.password = $("#pwd-password").val();
  var cpwd=$("#cpwd").val();
  var pwd = data.password;

  if(cpwd!=pwd){
    alert('请重新输入二次密码,注册失败');
  } else{

  $.ajax({

    url: "/user/register",
    data: data,
    method: "POST",
    success: function (ret){
       console.log(ret);
      if(ret.success){
          location.replace('./loginPage.html');// /views/loginPage.html'
          alert('success!');
        }else {
        alert(ret.msg);
      }
    },
    error: function (err) {
      console.log("register:You got error man!!!?");
    }

  });
}
}
//  password show n hide functionality
function showHidePwd() {
  const currentType = $(".pwd").attr("type");
  if (currentType == "password") {
    $(".pwd").attr("type", "text");
  } else {
    $(".pwd").attr("type", "password");
  }
}


